package com.asl.website.joinModule.domain;

/**
 * @author 482944566@qq.com
 * @version 1.0
 * @date 2025-05-22
 */

import com.asl.common.utils.StringUtils;
import com.asl.website.common.Language;

/**
 * 加入我们模块响应DTO
 */
public class JoinModuleDTO {
    private Long id;
    private String moduleName;
    private String title;
    private String content;
    private String icon;
    private Integer sortOrder;
    private String language;

    public JoinModuleDTO(AslJoinModule module, String language) {
        this.id = module.getId();
        this.moduleName = module.getModuleName();
        this.icon = module.getIcon();
        this.sortOrder = module.getSortOrder();
        this.language = language;

        switch (Language.fromCode(language)) {
            case EN_US:
                this.title = StringUtils.firstNonBlank(module.getTitleEn(), module.getTitleZh());
                this.content = StringUtils.firstNonBlank(module.getContentEn(), module.getContentZh());
                break;
            case DE_DE:
                this.title = StringUtils.firstNonBlank(module.getTitleDe(), module.getTitleZh());
                this.content = StringUtils.firstNonBlank(module.getContentDe(), module.getContentZh());
                break;
            default: // 默认中文
                this.title = module.getTitleZh();
                this.content = module.getContentZh();
        }
    }

    // getters
    public long getId() {
        return id;
    }

    public String getModuleName() {
        return moduleName;
    }

    public String getTitle() {
        return title;
    }

    public String getContent() {
        return content;
    }

    public String getIcon() {
        return icon;
    }

    public Integer getSortOrder() {
        return sortOrder;
    }


    public String getLanguage() {
        return language;
    }
}